//
//  SickInfoVC.m
//  Doctor
//
//  Created by 阳光 on 16/9/28.
//  Copyright © 2016年 阳光. All rights reserved.
//  不孕治疗

#import "SickInfoVC.h"
#import "SickModel.h"

static NSString *tableViewCellIdentifier=@"UITableViewCellIdentifier";

@interface SickInfoVC ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,strong)UITableView *sickInfoTableView;

@property(nonatomic,strong)NSMutableArray *sickArr;

@end

@implementation SickInfoVC

- (void)viewDidLoad
{
    [super viewDidLoad];

    _sickArr=[NSMutableArray array];
    
    self.title=@"不孕治疗";
    
    [self initNavBarBtnItem];
    
    [self initTableView];
    
    [self getSickListData];
    
}

-(void)getSickListData
{
    
    _sickArr=[SickModel mj_objectArrayWithKeyValuesArray:_patientInfoDic[@"case_cupai"]];
    [_sickInfoTableView reloadData];
    
}

-(void)initTableView
{
    // _sickInfoTableView
    _sickInfoTableView=[[UITableView alloc]initWithFrame:CGRectMake(0,0,APPW,APPH-49) style:UITableViewStylePlain];
    _sickInfoTableView.delegate=self;
    _sickInfoTableView.dataSource=self;
    _sickInfoTableView.hidden=NO;
    _sickInfoTableView.backgroundColor=MAIN_BACK_COLOR;
    _sickInfoTableView.showsVerticalScrollIndicator=NO;
    _sickInfoTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_sickInfoTableView];
    [_sickInfoTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:tableViewCellIdentifier];
    
    UIView *headView=[UIView new];
    headView.frame=CGRectMake(0,0,APPW,kmargin*5);
    headView.backgroundColor=WhiteColor;
    
    UILabel *userLabel=[headView getLabelWithText:@"没有做IVF前,曾用过促排药物如下:" font:Font_Number(16) textColor:Main_Color textAlignment:NSTextAlignmentCenter lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
    [headView addSubview:userLabel];
    [userLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(kmargin*2);
        make.right.mas_equalTo(-kmargin*2);
    }];
    
    _sickInfoTableView.tableHeaderView=headView;

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.sickArr.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:tableViewCellIdentifier];
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    SickModel *sickModel=self.sickArr[indexPath.row];
    cell.textLabel.text=sickModel.drug;
    cell.textLabel.textAlignment=NSTextAlignmentCenter;
    return cell;
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return kmargin*2;
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *footView=[UIView new];
    return footView;
}

-(void)initNavBarBtnItem
{
    self.navigationItem.leftBarButtonItem=[UIBarButtonItem initWithNormalImage:@"back_gray" target:self action:@selector(backItemEvent)];
}

-(void)backItemEvent
{
    [self.navigationController popViewControllerAnimated:NO];
}


@end
